From 7215c7493380157aa4673cb0df2f38c82284c377 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Nov 2020 19:19:40 -0500 Subject: [PATCH] buildertool: Supplant a requires When we convert a ui file to GTK 4 syntax, we *know* that it requires GTK 4, so put that in the output. --- gtk/tools/gtk-builder-tool-simplify.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c index 9e3324306d..868d0dc49a 100644 --- a/gtk/tools/gtk-builder-tool-simplify.c +++ b/gtk/tools/gtk-builder-tool-simplify.c @@ -62,6 +62,7 @@ typedef struct { char *output_filename; FILE *output; gboolean convert3to4; + gboolean has_gtk_requires; } MyParserData; static void @@ -1640,7 +1641,10 @@ rewrite_requires (Element *element, MyParserData *data) { if (has_attribute (element, "lib", "gtk+")) - set_attribute_value (element, "lib", "gtk"); + { + set_attribute_value (element, "lib", "gtk"); + set_attribute_value (element, "version", "4.0"); + } } static void @@ -2050,6 +2054,12 @@ enhance_element (Element *element, { GList *l; + if (strcmp (element->element_name, "requires") == 0 && + has_attribute (element, "lib", "gtk+")) + { + data->has_gtk_requires = TRUE; + } + add_old_default_properties (element, data); for (l = element->children; l; l = l->next) @@ -2057,6 +2067,13 @@ enhance_element (Element *element, Element *child = l->data; enhance_element (child, data); } + + if (element == data->root && !data->has_gtk_requires) + { + Element *requires = add_element (element, "requires"); + set_attribute_value (requires, "lib", "gtk+"); + set_attribute_value (requires, "version", "3.0"); + } } static void @@ -2144,6 +2161,7 @@ simplify_file (const char *filename, data.input_filename = filename; data.output_filename = NULL; data.convert3to4 = convert3to4; + data.has_gtk_requires = FALSE; if (replace) { -- 2.30.2